<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改焊接计划表')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-welding-edit" th:object="${planWelding}">
            <input name="sbId" th:field="*{sbId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">焊接台编号：</label>
                <div class="col-sm-8">
                    <input name="sbId" th:field="*{sbId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">存货编码：</label>
                <div class="col-sm-8">
                    <input name="productId" th:field="*{productId}" class="form-control" type="text">
                    <a id="selectProduct" class="btn btn-success" onclick="selectProduct()" >
                         ...
                    </a>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">焊接次数：</label>
                <div class="col-sm-8">
                    <input name="number" th:field="*{number}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">计划数量：</label>
                <div class="col-sm-8">
                    <input name="planQuantity" th:field="*{planQuantity}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">完成数量：</label>
                <div class="col-sm-8">
                    <input name="finishQuantity" th:field="*{finishQuantity}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">当前模式：</label>
                <div class="col-sm-8">
                    <input name="status" th:field="*{status}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "plan/welding";
        $("#form-welding-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-welding-edit').serialize());
            }
        }
        //选择物资
        function selectProduct() {
            var options = {
                title: '选择物品信息',
                url: "/plan/welding/selectPro",
                callBack: getMembers
            };
            $.modal.openOptions(options);

        }

        function getMembers(index, layero) {

            var row = layero.find("iframe")[0].contentWindow.submitHandler();
            if (row.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }

            var zTreeDoorData = [];
            zTreeDoorData.splice(0, zTreeDoorData.length);

            for (var i = 0; i < row.length; i++) {
                $('#productId').val(row[i].productId);
                $('#number').val(row[i].specialFlag);
                $('#finishQuantity').val(0);
                $('#status').val(0);

            }
            $.modal.close(index);
            $.modal.closeLoading();

        }
    </script>
</body>
</html>